<% layout('/layouts/default.html', {title: '流程部署定义', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('流程部署定义')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${processDefinition}" action="${ctx}/flow/definition/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('流程KEY')}：</label>
					<div class="control-inline">
						<#form:input path="key" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('流程名称')}：</label>
					<div class="control-inline">
						<#form:input path="name" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-search"></i> ${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm isQuick"><i class="glyphicon glyphicon-repeat"></i> ${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
//# // 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $('#searchForm'),
	columnModel: [
		{header:'${text("流程ID")}', name:'id', width:120, align:"left"},
		{header:'${text("流程KEY")}', name:'key', width:120, align:"center"},
		{header:'${text("流程名称")}', name:'name', width:150, align:"center"},
		{header:'${text("版本")}', name:'version', width:50, align:"center"},
		{header:'${text("流程描述")}', name:'description', width:180, align:"left"},
		{header:'${text("所属分类")}', name:'category', width:100, align:"left"},
		{header:'${text("部署时间")}', name:'deploymentTime', width:120, align:"left"},
		{header:'${text("流程定义")}', name:'resourceName', width:150, align:"left", frozen:true, fixed:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/flow/definition/readResource?pdid='+row.id+'&resourceName='+val+'" target="_blank">'+val+'</a>';
		}},
		{header:'${text("流程图")}', name:'diagramResourceName', width:150, align:"left", frozen:true, fixed:true, formatter: function(val, obj, row, act){
				return '<a href="${ctx}/flow/definition/readResource?pdid='+row.id+'&resourceName='+val+'" target="_blank">'+row.key+'.png</a>';
		}},
		{header:'${text("流程定义状态")}', name:'suspendState', width:90, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel("#{@DictUtils.getDictListJson('flow_definition_status')}", val, '${text("未知")}', true);
		}},
		{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
			var actions = [];
			if (row.suspendState == 2){
				actions.push('<a href="${ctx}/flow/definition/suspendOrActiveApply?id='+row.id+'&suspendState=1" class="btnList" title="${text("激活流程定义")}" data-confirm="${text("确认要激活该流程定义吗？")}"><i class="icon-check" style="color: #108c53;"></i></a>&nbsp;');
			} else if (row.suspendState == 1){
				actions.push('<a href="${ctx}/flow/definition/suspendOrActiveApply?id='+row.id+'&suspendState=2" class="btnList" title="${text("挂起流程定义")}" data-confirm="${text("确认要挂起该流程定义吗？")}"><i class="icon-ban" style="color: #dd5a43;"></i></a>&nbsp;');
			}
			actions.push('<a href="${ctx}/flow/definition/convert2Model?processDefinitionId='+row.id+'" class="btnList" title="${text("转换模型定义")}" data-confirm="${text("确认要转换成流程模型吗？")}"><i class="icon-refresh"></i></a>');
			actions.push('<a href="${ctx}/flow/definition/remove?deploymentId='+row.deploymentId+'" class="btnList" title="${text("删除流程定义")}" data-confirm="${text("确认要删除该流程定义吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			return actions.join('');
		}}
	],
	//# // 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>